package com.easymin.weixin.manager;

import java.util.Date;
import java.util.List;
import java.util.Map;

import com.easymin.weixin.common.DataGrid;
import com.easymin.weixin.controller.v4.ResultTransport;
import com.easymin.weixin.controller.v5.utils.ResultV5;
import com.easymin.weixin.entity.Order;
import com.easymin.weixin.entity.OrderType;

public interface ErrandManager {
  /**
   * 下单方法.
   */
  Map<String, Object> createOrder(
      String title, String content, String deliverTime, String deliverAddress, 
      Double deliverLat, Double deliverLng, Boolean errandFixPrice, Double shouldPay, 
      Long passengerId, String phone, String channelName, String openId, Long companyId,
      String companyName, String startTime, String startPhone, String endPhone,
      String startAddress, Double startLat, Double startLng, String orderType,
      Double startPrice, Double mileagePrice, Double travelTimePrice, Integer travelTime,
      Double mileage, String appKey) throws Exception;

  int saveOrderImgs(Long orderId, String channelName, String imgs, String appKey);

  /**
   * 根据订单状态分页查询订单.
   *
   * @param passengerId 乘客id
   * @param status "present":当前订单(0:新单1:已派单2:已接单3:执行中),
   *        "noreview"未评价(6:已完成(未评价)),"already"已完成    (4:已完成) 5:已销单
   */
  DataGrid<Map<String, Object>> findOrder(Long passengerId, Integer page, Integer rows,
      String status, String appKey) throws Exception;

  /**
   * 修改订单状态.
   */
  String updateStatus(Long orderId, Long employId, String employName, String employPhone,
      Long employCompanyId, String action, String operator, String cancelCause, String appKey);

  /**
   * 评价订单.
   */
  String review(Long orderId, Double score, String content, String appKey);

  /**
   * 查询最新订单(新订单:status=0).
   */
  DataGrid<Map<String, Object>> findNewOrder(Integer page, Integer rows, String appKey);

  /**
   * 查询附近新订单 (新订单:status=0).
   */
  DataGrid<Map<String, Object>> findNearOrder(Double longitude, Double latitude, Double distance,
      Integer page, Integer rows, String appKey);

  /**
   * 查询单个订单.
   */
  Order findOne(Long orderId, String appKey) throws Exception;

  /**
   * 司机查询当前的任务.
   */
  DataGrid<Map<String, Object>> findMyWork(Long employId, Double longitude, Double latitude,
      Integer page, Integer rows, String appKey);

  /**
   * 查询司机端三个列表的订单数量.
   */
  Map<String, Object> queryCount(Long employId, Double longitude, Double latitude, Double distance,
      String appKey);

  /**
   * 查询客户端三个列表的数量.
   */
  Map<String, Object> queryOrders(Long passengerId, String appKey);

  /**
   * 获取收费标准.
   */
  String findErrandPay(String city, String acKey, String appKey);

  /**
   * 催一下.
   */
  String hasten(Long orderId, String appKey);

  Map<String, Object> toGrabOrder(Long orderId, Long employId, String employName,
      String employPhone, Long employCompanyId, Double distance, String appKey);

  Map<String, Object> grabOrder(
      Long orderId, Long employId, Integer errandGrabAmount, String appKey);

  Map<String, Object> grabTime(Long orderId, String appKey);

  // 第二版跑腿抢单接口
  Map<String, Object> grab(String employName, String employPhone, Double distance,
      final Long orderId, final Long employId, final Long employCompanyId,
      Integer errandGrabAmount, final String appKey);

  // v2查询跑腿类型
  List<OrderType> findByCompanyId(Long companyId, String appKey);

  // v2版本的跑腿下单
  Order saveOrder(Long passengerId, String passengerName, String passengerPhone, Long companyId,
      String companyName, String startAddress, Double startLat, Double startLng,
      String deliverAddress, Double deliverLat, Double deliverLng, String channelName,
      Date startDate, Double startPrice, Double mileagePrice, Double travelTimePrice,
      Double mileage, Integer travelTime, Double shouldPay, Long orderTypeId, Long couponId,
      String content, String imgs, String voiceUrl, Long employId, Long employCompanyId,
      String employName, String employPhone, String appKey, String startDetailed,
      String endDetailed, String recipients, String phone, String weight,String buyNeeds,Double goodsCash,Double thanksCash,String addServices,String tips,String matter,boolean prePay,String payType,String address);

  // v2查询单个跑腿订单
  Map<String, Object> findOrderV2(Long orderId, String appKey, String address) throws Exception;

  /**
   * v2根据订单状态分页查询订单.
   *
   * @param passengerId 乘客id
   */
  DataGrid<Map<String, Object>> findOrderV2(Long passengerId, Integer page, Integer rows,
      String appKey, String address) throws Exception;

  String reviewV2(Long orderId, Double score, String content, String appKey);

  String updateStatusV2(Long orderId, Long employId, String employName, String employPhone,
      Long employCompanyId, String action, String operator, String cancelCause, String appKey);

  String hastenV2(Long orderId, String appKey);

  Order findOneOrderV2(Long orderId, String appKey);

  DataGrid<Map<String, Object>> findMyWorkV2(Long employId, Double longitude, Double latitude,
      Integer page, Integer rows, String appKey, String address);

  /**
   * V2查询服务人员已完成的订单.
   */
  DataGrid<Map<String, Object>> queryFinishOrderV2(Long employId, Integer page, Integer rows,
      String appKey);

  /**
   * V2抢单.
   */
  Map<String, Object> grabV2(String employName, String employPhone, Double distance,
      final Long orderId, final Long employId, final Long employCompanyId, final String appKey);

  Map<String, Object> grabOrderV2(Long orderId, Long employId, String appKey);

  OrderType findOrderType(Long orderTypeId, String appKey);

  /**
   * V2微信下单.
   */
  Map<String, Object> saveWeixinOrder(Long passengerId, String passengerName,
      String passengerPhone, String startAddress, Double startLat, Double startLng,
      String deliverAddress, Double deliverLat, Double deliverLng, Double startPrice,
      Double mileagePrice, Double travelTimePrice, Double mileage, Integer travelTime,
      Double shouldPay, Long orderTypeId, String content, String appKey, String channelName,
      String serverAddress);

  /**
   * V4查询单个跑腿订单.
   */
  ResultTransport findOrderV4(Long orderId, String appKey, String address);

  /**
   * 查询跑腿类型.
   */

  ResultTransport queryTypeV4(Long companyId,String detailedJobType, String appKey);

  /**
   * 查询跑腿类型V5.
   */
  ResultV5 queryTypeV5(Long companyId, String appKey);

  ResultTransport jiedan(Long orderId, Long employId, String employName, String employPhone,
      Long companyId, String employAccount, String employPhoto, Double employScore,
      String operator, String appKey, String errandserviceType, String platNo);

  ResultTransport refuse(
      Long orderId, Long employId, String cause, String employName, String appKey);

  ResultTransport runV4(Long orderId, String operator, String appKey);

  /**
   * V4抢单_添加抢单记录.
 * @param platNo 
 * @param errandserviceType 
   */
  ResultTransport toGrabOrderV4(Long orderId, Long employId, String employName, String employPhone,
      Long companyId, Double employLat, Double employLng, String appKey, String errandserviceType, String platNo);

  /**
   * V4抢单_指派订单.
   */
  ResultTransport grabOrderV4(Long orderId, Long employId, String serverUrl, String appKey);

  /**
   * V4销单(司机端).
   */
  ResultTransport cancelV4(Long orderId, String cause, String appKey);

  /**
   * V4查询单个跑腿类型.
   */
  ResultTransport findOrderTypeV4(Long orderTypeId, String appKey);

  ResultTransport saveOrderV4(Long passengerId, String passengerName, String passengerPhone,
      Long companyId, String companyName, String startAddress, Double startLat, Double startLng,
      String deliverAddress, Double deliverLat, Double deliverLng, String channelName,
      Double startPrice, Double mileagePrice, Double travelTimePrice, Double mileage,
      Integer travelTime, Double shouldPay, Long orderTypeId, Long couponId, String content,
      String imgs, String voiceUrl, Long employId, Long employCompanyId, String employName,
      String employPhone, String appKey,Double weight);

  /**
   * V4修改跑腿订单的结束地点.
   */
  ResultTransport updateToPlace(Long orderId, String toPlace, Double longitude, Double latitude,
      String appKey);

  Long countRunning(Long passengerId, String appKey);

  Long countNotPayAmounts(Long passengerId, String appKey);

  /**
   * 查询未完成单量
   */
  Long countNotFinishedByPassenger(Long passengerId, String appKey);
}
